#include "InSdkIniConfig.h"
#include "InSdkIniBasic.h"
#include "InSdkIniDev.h"

#define DEF_TAG "IniConf"

Com_ps8 Ext_InSdkIniCfg_CheckTypeStr(Com_ps8 key)
{
    if (key == NULL)
    {
        static Com_s8 str[4] = "01";
        PRT_WARN(DEF_TAG, "Str is NULL");
        return str;
    }

    return key;
}

Com_void Ext_InSdkIniCfg_Recover(struct config *conf, Com_ps8 key)
{
    PRT_WARN(DEF_TAG, "no %s\n", key);
    conf_set_string(conf, key, "0");
    conf_save(conf);
}

Com_void Ext_InSdkIniCfg_Check(Com_ps8 file)
{
    struct config *conf = NULL;
    Com_s32 cnt = 0;

    while (cnt < 3)
    {
        conf = conf_load(file);
        if (conf == NULL)
        {
            Ext_InComFile_JudgeRemove(file);
            Ext_InComFile_JudgeCreat(file);
            cnt++;
        }
        else
        {
            break;
        }
    }

    conf_unload(conf);
}

Com_void Ext_InSdkIniCfg_Init(Com_void)
{
    Ext_InSdkIniBasic_Init();
    Ext_InSdkIniIot_Init();
}

Com_void Ext_InSdkIniCfg_Exit(Com_void)
{
    Ext_InSdkIniBasic_Exit();
    Ext_InSdkIniIot_Exit();
}
